/**
 * Created by yby on 2019/2/13 10:31.
 */

var blockquote_padding = "3px";  //每层房源标签内边距
var blockquote_min_height = "60px";  //每层房源标签高度

//封装楼盘图（伪选为黄色）
function getPicture(data) {
    var maxFloor = data.maxFloor;
    var floorHouseMap = data.floorHouseMap;
    var colorMap = data.colorMap;
    var houseHoldMap = data.houseHoldMap;
    var pictureHtml = "<div class='layui-container' style='width: 100%'><table style='width: 100%'>";
    for (var i = maxFloor; i > 0; i--) {
        pictureHtml = pictureHtml + "<tr><td style='width: 4%;text-align: right;'>" + i + "层&nbsp;&nbsp;</td>";
        pictureHtml = pictureHtml + "<td style='width: 96%'><blockquote class='layui-elem-quote' style='padding: " + blockquote_padding + ";float: left;width: 100%;min-height: " + blockquote_min_height + ";'>";
        var houseList = floorHouseMap[i + ""];
        if (houseList != undefined) {  //楼层房源为空的不循环
            for (var j = 0; j < houseList.length; j++) {
                var house = houseList[j];
                pictureHtml = pictureHtml + "<div style='background-color: " + colorMap[house.houseStatus] + "' id='" + house.id + "' houseStatus = '" + house.houseStatus + "' class='houseStyle'>" + house.houseNum + "(" + house.buildArea + ")<br/>" + houseHoldMap[house.houseHold] + "</div>";
            }
        }
        pictureHtml = pictureHtml + "</blockquote></td></tr>";
    }
    pictureHtml = pictureHtml + "</table></div>";
    return pictureHtml;
}

//封装选房楼盘图（伪选为红色）
function getChooseHousePicture(data) {
    var maxFloor = data.maxFloor;
    var floorHouseMap = data.floorHouseMap;
    var colorMap = data.colorMap;
    var houseHoldMap = data.houseHoldMap;
    var pictureHtml = "<div class='layui-container' style='width: 100%'><table style='width: 100%'>";
    for (var i = maxFloor; i > 0; i--) {
        pictureHtml = pictureHtml + "<tr><td style='width: 4%;text-align: right;'>" + i + "层&nbsp;&nbsp;</td>";
        pictureHtml = pictureHtml + "<td style='width: 96%'><blockquote class='layui-elem-quote' style='padding: " + blockquote_padding + ";float: left;width: 100%;min-height: " + blockquote_min_height + ";'>";
        var houseList = floorHouseMap[i + ""];
        if (houseList != undefined) {  //楼层房源为空的不循环
            for (var j = 0; j < houseList.length; j++) {
                var house = houseList[j];
                var houseStatus = house.houseStatus;
                pictureHtml = pictureHtml + "<div style='background-color: " + colorMap[houseStatus] + "' id='" + house.id + "' houseStatus='" + houseStatus + "' class='houseStyle'>" + house.houseNum + "(" + house.buildArea + ")<br/>" + houseHoldMap[house.houseHold] + "</div>";
            }
        }
        pictureHtml = pictureHtml + "</blockquote></td></tr>";
    }
    pictureHtml = pictureHtml + "</table></div>";
    return pictureHtml;
}

//封装选房楼盘图（伪选为红色）
function getChooseHousePictureForLimit(data) {
    var maxFloor = data.maxFloor;
    var floorHouseMap = data.floorHouseMap;
    var colorMap = data.colorMap;
    var houseHoldMap = data.houseHoldMap;
    var limitMemo = data.limitMemo;
    var pictureHtml = "<div style='color: red'>" + limitMemo + "</div>";
    pictureHtml = pictureHtml + "<div class='layui-container' style='width: 100%'><table style='width: 100%'>";
    for (var i = maxFloor; i > 0; i--) {
        pictureHtml = pictureHtml + "<tr><td style='width: 4%;text-align: right;'>" + i + "层&nbsp;&nbsp;</td>";
        pictureHtml = pictureHtml + "<td style='width: 96%'><blockquote class='layui-elem-quote' style='padding: " + blockquote_padding + ";float: left;width: 100%;min-height: " + blockquote_min_height + ";'>";
        var houseList = floorHouseMap[i + ""];
        if (houseList != undefined) {  //楼层房源为空的不循环
            for (var j = 0; j < houseList.length; j++) {
                var house = houseList[j];
                var houseStatus = house.houseStatus == 2 ? 2 : house.houseStyle;
                pictureHtml = pictureHtml + "<div style='background-color: " + colorMap[houseStatus] + "' id='" + house.id + "' houseStatus='" + house.houseStatus + "' class='houseStyle'>" + house.houseNum + "(" + house.buildArea + ")<br/>" + houseHoldMap[house.houseHold] + "</div>";
            }
        }
        pictureHtml = pictureHtml + "</blockquote></td></tr>";
    }
    pictureHtml = pictureHtml + "</table></div>";
    return pictureHtml;
}

//封装楼盘图（房源分配） 添加单选按钮
function getZsProjectHousePicture(data) {
    var maxFloor = data.maxFloor;
    var floorHouseMap = data.floorHouseMap;
    var colorMap = data.colorMap;
    var houseHoldMap = data.houseHoldMap;
    var houseIdMap = data.houseIdMap;   //已经分配的房源Id
    var pictureHtml = "<div class='layui-container' style='width: 100%'><table style='width: 100%'>";
    pictureHtml = pictureHtml + "<tr><td style='width: 4%;'><input type='checkbox' name='allChoose' lay-filter='checkAll' value='' lay-skin='primary' title='全选'/>&nbsp;&nbsp;</td><td style='width: 96%'></td></tr>"
    for (var i = maxFloor; i > 0; i--) {
        pictureHtml = pictureHtml + "<tr><td style='width: 4%;'><input type='checkbox' name='floor' lay-filter='checkFloor' value='" + i + "' lay-skin='primary' title='" + i + "层'/>&nbsp;&nbsp;</td>";
        pictureHtml = pictureHtml + "<td style='width: 96%'><blockquote class='layui-elem-quote' style='padding: " + blockquote_padding + ";float: left;width: 100%;min-height:" + blockquote_min_height + ";'>";
        var houseList = floorHouseMap[i + ""];
        if (houseList != undefined) {  //楼层房源为空的不循环
            for (var j = 0; j < houseList.length; j++) {
                var house = houseList[j];
                var checked = "";
                var inputValue = "";
                if (houseIdMap[house.id] == house.id) {
                    checked = "checked";
                    inputValue = house.id;  //当房源已被分配，将输入框赋值
                }
                pictureHtml = pictureHtml + "<div style='background-color: " + colorMap[house.houseStatus] + ";' class='houseStyle'>";
                pictureHtml = pictureHtml + "<input type='hidden' name='houseIds' value='" + inputValue + "'/>";
                pictureHtml = pictureHtml + "<input type='checkbox' " + checked + " disabled name='houseId' value='" + house.id + "' houseStatus = '" + house.houseStatus + "' floor='" + i + "' lay-skin='primary' title=''/>" + house.houseNum + "<br/>" + "<span style='font-size: 10px;'>(" + house.buildArea + ")" + houseHoldMap[house.houseHold] + "</span>";
                pictureHtml = pictureHtml + "</div>"
            }
        }
        pictureHtml = pictureHtml + "</blockquote></td></tr>";
    }
    pictureHtml = pictureHtml + "</table></div>";
    return pictureHtml;
}

